/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package games.Kamisado;

import games.Heuristic;
import games.KamisadoState;
import games.Tower;

/**
 *
 * @author Mikael
 */
/*public class Mikael3Heuristic implements Heuristic<KamisadoState> {
    private boolean isStart;

    @Override
    public int evaluate(KamisadoState state) {
        boolean ownerValue = !isStart;

        int score = 0;
        for (Tower tower : state.getAllTowers()) {
            score += getPositionScore(tower, ownerValue);
            score += getBlockedScore(tower, ownerValue, state);
        }

        return score;
    }

    private int getPositionScore(Tower tower, boolean ownerValue) {
        if (tower.getPlayer() == ownerValue) {
            return (7 - tower.getY()) * 10;
        } else {
            return tower.getY() * 10;
        }
    }
    
    private int getBlockedScore(Tower tower, boolean ownerValue, KamisadoState state) {
        if (tower.getPlayer() == ownerValue) {
            int y = tower.getY() -1;
            if(y < 0){
                return 0;
            }
            for (int x = Math.max(0, tower.getX() - 1); x < Math.min(7, tower.getX()); x++) {
                if(state.getTower(x, tower.getY() - 1) == null){
                    return 0;
                }
            }
            return -2000;
        }else{
            int y = tower.getY() + 1;
            if(y > 7){
                return 0;
            }
            for (int x = Math.max(0, tower.getX() - 1); x < Math.min(7, tower.getX()); x++) {
                if(state.getTower(x, y) == null){
                    return 0;
                }
            }
            return 2000;
        }
    }
    
    @Override
    public void setAsStartPlayer(boolean isStart) {
        this.isStart = isStart;
    }
}*/
